<?php

class Application_Form_SecretaryShopAssistant extends Zend_Form
{
    public function init()
    {
        $ac_ajax_zipCode = new ZendX_JQuery_Form_Element_AutoComplete("zipCode");
        $ac_ajax_zipCode->setLabel("Kod pocztowy");
        $ac_ajax_zipCode->setAttrib('class', array('validate[custom[zipCode]]'))->setJQueryParams(array(
                'data' => '/secretary/autocomplete-zip-code',
                'delay' => 300,
                'minLength' => 4,
        ));

        $ac_ajax_zipCode->addValidator('regex', false, array('/^\d\d-\d\d\d$/'));
        $this->addElement($ac_ajax_zipCode, "zipCode" . $lp);



        $ac_ajax_city = new ZendX_JQuery_Form_Element_AutoComplete("city");
        $ac_ajax_city->setLabel("Miejscowość");
        $ac_ajax_city->setJQueryParams(array(
                'data' => '/secretary/autocomplete-city',
                'delay' => 300,
                'minLength' => 3
        ));
        $this->addElement($ac_ajax_city, "city" . $lp);



        $ac_ajax_idPartner = new ZendX_JQuery_Form_Element_AutoComplete("idPartnerSearch");
        $ac_ajax_idPartner->setLabel("znajdź / zmień:")
                          ->setAttrib('size',100)
                          ->setJQueryParams(array(
                                'data' => '/secretary/ac-partner',
                                'delay' => 300,
                                'minLength' => 3,
                                'select' => new Zend_Json_Expr('
                                    function(event,ui) { 
                                        $("#idPartner").val(ui.item.id) 
                                    }')));
        $this->addElement($ac_ajax_idPartner, "idPartnerSearch");



        $ac_ajax_us = new ZendX_JQuery_Form_Element_AutoComplete("us");
        $ac_ajax_us->setLabel("U. Skarbowy")
                   ->setAttrib('size',100)
                   ->setJQueryParams(array(
                        'data' => '/secretary/autocomplete-us',
                        'delay' => 300,
                        'minLength' => 3
        ));
        $this->addElement($ac_ajax_us, "us" . $lp);



        $this->addElement('hidden', 'idPartner' . $lp);
        $this->getElement('idPartner' . $lp)->setDecorators(
            array('ViewHelper', 'Description', 'Errors', 'Label',
                array(array('data' => 'HtmlTag'), array('tag' => 'span')),
                array(array('row' => 'HtmlTag'), array('tag' => 'span'))));
        

        $this->setDecorators(array(array('ViewScript', array('viewScript' => 'secretary/vsSecretaryShopAssistant.phtml'))));
    }
}